package com.woniuxy.controller;

import com.woniuxy.entity.ResponseEntity;
import com.woniuxy.entity.Style;
import com.woniuxy.service.StyleService;
import com.woniuxy.utils.CodeUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/style")
public class StyleController {

    @Autowired
    private StyleService styleService;

    /**
     * 获取所有的流派
     * @return ResponseEntity
     */
    @GetMapping("/all")
    public ResponseEntity<List<Style>> findAllStyles(){
        ResponseEntity<List<Style>> styleListResponseEntity = new ResponseEntity<>();
        List<Style> allStyles = styleService.findAllStyles();
        if (allStyles!=null){
            return styleListResponseEntity.setData(allStyles)
                    .setMsg("here you go").setCode(CodeUtils.SUCCESS_CODE);
        }else return styleListResponseEntity.setCode(CodeUtils.ERROR_CODE).setMsg("emm~,有问题");

    }
}
